package com.technology.education.dslitem

import androidx.core.view.updateLayoutParams
import com.angcyo.dsladapter.DslAdapterItem
import com.angcyo.dsladapter.DslViewHolder
import com.angcyo.dsladapter.dpi
import com.google.android.material.imageview.ShapeableImageView
import com.technology.education.R
import com.technology.education.ext.loadImage

class ItemSingleImage(var imgUrl: String = "", var size: Int = 88*dpi) : DslAdapterItem() {
    init {
        itemLayoutId = R.layout.item_single_image
    }

    override fun onItemBind(
        itemHolder: DslViewHolder,
        itemPosition: Int,
        adapterItem: DslAdapterItem,
        payloads: List<Any>
    ) {
        super.onItemBind(itemHolder, itemPosition, adapterItem, payloads)

        itemHolder.v<ShapeableImageView>(R.id.iv_image)?.apply {
            loadImage(imgUrl, this)
            updateLayoutParams {
                width = size
                height = size
            }
        }
        itemHolder.clickItem(_clickListener)
    }
}